Spinner入门实例
前段代码:
后端代码:
package com.test; import android.app.Activity; import android.os.Bundle; public class MainActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); String strs[] = new String[] { "aaaaa", "bbbb", "ccccc", "dddddddddddd" }; android.widget.ArrayAdapter arrayAdapter = new android.widget.ArrayAdapter( this, android.R.layout.simple_spinner_item, strs); arrayAdapter .setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); android.widget.Spinner spinner = (android.widget.Spinner) this .findViewById(R.id.spinner); spinner.setAdapter(arrayAdapter); // spinner.setOnItemClickListener(l) } }
评论